// pages/detail/detail.js
const app = getApp();
const {
  get
} = require('../../utils/request')
const {
  baseUrl
} = require('../../utils/config')
Page({
  data: {
    baseUrl: baseUrl,
    articleDetailData: {},
    category_name: ''
  },
  onLoad(options) {
    this.getArticleDetailById(options.article_id)
  },
  onBack() {
    wx.navigateBack()
  },
  //  通过文章id获取文章数据
  async getArticleDetailById(article_id) {
    let result = await get(`${baseUrl}articleDetailById`,{article_id})
    const category_id = result.category_id
    // 通过id获取分类名称
    let nameResult = await get(`${baseUrl}categoryNameById`,{category_id})
    this.setData({
      articleDetailData: result,
      category_name: nameResult
    })
  }
})